const a = async function (
  params,
  { transfer, dataId, memory, origin, me },
  { $grid, dc: { http }, xe: { clone, get, omit, set, mapTree } }
) {
  console.log("load grid data: ", $grid, params, dataId);
  const post = omit(params, ["guid"]);
  if (params.guid && params.guid.join("") != "0")
    post.enterpriseGuid = params.guid.join("");
  const form = clone(get(origin, "1797803362328653826", {}), true);
  const data = {
    ...post,
    ...omit(form ?? {}, ["condition", "dataCondition", "local"]),
  };
  const unit = form.local.unit ?? 10000;
  mapTree($grid.columns, function (it) {
    const isMoneyField =
      it.formatter && (it.formatter == "money" || it.formatter[0] == "money");
    console.log(isMoneyField, it, it.children);
    if (isMoneyField) it.formatter = ["money", unit];
    return it;
  });
  const conditionList = get(memory, "condition", []);
  const conditions = form.condition
    ? conditionList
        .filter(function ({ id }) {
          return form.condition.indexOf(id) > -1;
        })
        .map(function ({ condition }) {
          return condition;
        })
    : [];
  if (conditions.length) {
    data["condition"] = conditions.join("");
  }
  conditionList.map(({ condition }) => {
    const fields = condition.slice(0, -1).split(",");
    if (conditions.indexOf(condition) > -1) {
      fields.map((field) => $grid.showColumn($grid.getColumnByField(field)));
    } else {
      fields.map((field) => $grid.hideColumn($grid.getColumnByField(field)));
    }
  });
  const dataConditionList = get(memory, "dataCondition", []);
  const dataConditions = form.dataCondition
    ? dataConditionList
        .filter(function ({ lid }) {
          return form.dataCondition.indexOf(lid) > -1;
        })
        .map(function ({ condition }) {
          return condition;
        })
    : [];
  if (dataConditions.length) {
    data["dataCondition"] = dataConditions.join("");
  }
  dataConditionList
    .filter(({ condition }) => condition)
    .map(({ condition, showParam }) => {
      const func =
        dataConditions.indexOf(condition) > -1 ? "showColumn" : "hideColumn";
      $grid[func]($grid.getColumnByField(showParam));
    });
  data["selectType"] = transfer.type == "yszx" ? 2 : 1;
  console.log("custom load: ", conditions, data, form, dataConditions);
  const {
    data: items,
    total,
    dataToTal,
  } = await http.post({
    timeout: 20 * 1000,
    url: "/qyk/search/listMoney",
    data: { ...data, hasSum: true },
  });
  console.log("dataToTal", dataToTal);
  if (dataToTal.MONEYTL || dataToTal.MONEYSL)
    dataToTal.totalMoney10 =
      (dataToTal.MONEYTL ?? 0) + (dataToTal.MONEYSL ?? 0);
  set(memory, `${me}.dataToTal`, dataToTal);
  console.log(
    `load(${me}): `,
    data,
    items,
    total,
    dataToTal,
    memory,
    $grid.columns
  );
  await $grid.reloadColumn($grid.columns);
  console.log("load: ", data, items, total);
  return { items, total };
};

const b = async function (
  params,
  { transfer, dataId, me, memory, origin },
  {
    $grid,
    dc: { http },
    helper: { treeMap },
    xe: { clone, get, mapTree, omit, set },
  }
) {
  console.log("load grid data: ", $grid.columns, params, dataId, origin);
  const post = omit(params, ["guid"]);
  if (params.guid && params.guid.join("") != "0")
    post.enterpriseGuid = params.guid.join("");
  const form = clone(get(origin, "1788122499964850177", {}), true);
  const data = {
    ...post,
    ...omit(form ?? {}, ["condition", "dataCondition", "local"]),
  };
  const unit = form.local.unit ?? 10000;
  mapTree($grid.columns, function (it) {
    const isMoneyField =
      it.formatter && (it.formatter == "money" || it.formatter[0] == "money");
    console.log(isMoneyField, it, it.children);
    if (isMoneyField) it.formatter = ["money", unit];
    return it;
  });
  const conditionList = get(memory, "condition", []);
  const conditions = form.condition
    ? conditionList
        .filter(function ({ id }) {
          return form.condition.indexOf(id) > -1;
        })
        .map(function ({ condition }) {
          return condition;
        })
    : [];
  if (conditions.length) {
    data["condition"] = conditions.join("");
  }
  conditionList.map(({ condition }) => {
    const fields = condition.slice(0, -1).split(",");
    if (conditions.indexOf(condition) > -1) {
      fields.map((field) => $grid.showColumn($grid.getColumnByField(field)));
    } else {
      fields.map((field) => $grid.hideColumn($grid.getColumnByField(field)));
    }
  });
  const dataConditionList = get(memory, "dataCondition", []);
  const dataConditions = form.dataCondition
    ? dataConditionList
        .filter(function ({ lid }) {
          return form.dataCondition.indexOf(lid) > -1;
        })
        .map(function ({ condition }) {
          return condition;
        })
    : [];
  if (dataConditions.length) {
    data["dataCondition"] = dataConditions.join("");
  }
  dataConditionList
    .filter(({ condition }) => condition)
    .map(({ condition, showParam }) => {
      const func =
        dataConditions.indexOf(condition) > -1 ? "showColumn" : "hideColumn";
      $grid[func]($grid.getColumnByField(showParam));
    });
  data["selectType"] = transfer.type == "yszx" ? 2 : 1;
  console.log("custom load: ", conditions, data, form);
  const {
    data: items,
    total,
    dataToTal,
  } = await http.post({
    timeout: 20 * 1000,
    url: "/nyk/search/listMoney",
    data: { ...data, hasSum: true },
  });
  items.map(function (it) {
    if (it.MONEYTL || it.MONEYSL)
      it.totalMoney10 = (it.MONEYTL ?? 0) + (it.MONEYSL ?? 0);
  });
  if (dataToTal.MONEYTL || dataToTal.MONEYSL)
    dataToTal.totalMoney10 =
      (dataToTal.MONEYTL ?? 0) + (dataToTal.MONEYSL ?? 0);
  set(memory, `${me}.dataToTal`, dataToTal);
  console.log(
    `load(${me}): `,
    data,
    items,
    total,
    dataToTal,
    memory,
    $grid.columns
  );
  await $grid.reloadColumn($grid.columns);
  return { items, total };
};
